import axios from '@/libs/api.request'

/**
 * 查询学校列表
 * SchoolListQueryVo{
    enable boolean
    pageNum integer($int32)
    pageSize integer($int32)
    schoolName string
   }
 */
export const schoolManageList = function (SchoolListQueryVo) {
    return axios.request({
        url: '/schoolManage/list',
        data: SchoolListQueryVo,
        method: 'post'
    })
}

/**
 * 删除学校信息
 *
 */
export const deleteSchool = id => {
    return axios.request({
        url: `/schoolManage/delete`,
        params: {
            id
        },
        method: 'get'
    })
}
/**
 * 新增学校
 * school {
  "addr": "string",
  "classIndex": 0,
  "contacts": "string",
  "createTime": "2020-04-21T04:18:54.675Z",
  "creator": "string",
  "enable": true,
  "modifier": "string",
  "modifyTime": "2020-04-21T04:18:54.676Z",
  "remark": "string",
  "schoolId": "string",
  "schoolName": "string",
  "tel": "string"
}
 */
export const addSchool = school => {
    return axios.request({
        url: `/schoolManage/add`,
        data: school,
        method: 'post'
    })
}

/**
 * 修改学校信息
 */
export const updateSchool = school => {
    return axios.request({
        url: `/schoolManage/update`,
        data: school,
        method: 'post'
    })
}

/**
 * 查询学校信息
 */
export const querySchoolInfo = id => {
    return axios.request({
        url: `/schoolManage/info`,
        params: {
            id
        },
        method: 'get'
    })
}

// 院系
export const queryColleges = () => {
    return axios.request({
        url: `/schoolManage/collegeNames`,
        method: 'get'
    })
}
export const delCollege = collegeId => {
    return axios.request({
        url: `/schoolManage/delCollege`,
        params: {
            collegeId
        },
        method: 'get'
    })
}
export const saveCollege = data => {
    return axios.request({
        url: `/schoolManage/saveCollege`,
        data,
        method: 'post'
    })
}

// 专业
export const queryMajors = (collegeId) => {
    return axios.request({
        url: `/schoolManage/majorNames`,
        params: {
            collegeId
        },
        method: 'get'
    })
}
export const delMajor = majorId => {
    return axios.request({
        url: `/schoolManage/delMajor`,
        params: {
            majorId
        },
        method: 'get'
    })
}
export const saveMajor = data => {
    return axios.request({
        url: `/schoolManage/saveMajor`,
        data,
        method: 'post'
    })
}

export const majorList = () => axios.request({
    url: `/schoolManage/majorList`,
    method: 'get'
})
